Wildcards in a Global Replace

A number of wildcards can be included in the Global Replace Text to find field.

To use wildcards:

  1. Place the cursor at the position in the Text to find field where you require a wildcard.
  2. Select the Regular Expression checkbox (placing a tick in it).
  3. Click Wildcards.

    A list of wildcards displays:

    Wildcards list

  4. Select one or more expressions from the list.

    Special marker characters are added to the Text to find box. Some, such as Character in range, require you to edit the expression and specify the characters.

    The following table describes the wildcards:

Wildcard

Name

Description

.

Any character

Matches any single character at that point in the Text to find field.

For example, locating

.x

and replacing with

y

will change a field that contains:

x x1 xx2

to:

y y1 yx2

[x-x]

Character in range

Matches one of the enclosed characters at that point in the Text to find. Can be a range (using the hyphen) or specific characters (without the hyphen).

For example:

c[ao]t

matches:

cat and cot

c[a-o]t will match:

cat, cbt, cct ... cot

^

Beginning of value

Matches a value at the start of the field (not within the field).

For example, to locate the letter A at the start of a field:

  1. Select Beginning of value from the list of Wildcards.

    The ^ wildcard is added to the Text to find field.

  2. After the ^, enter A, giving:

    ^A

$

End of value

Matches a value at the end of the field.

As with Beginning of value.

[[:<:]]

Beginning of word

Matches text at the start of a word.

For example, locating

[[:<:]]sm

and replacing with

sp

will change a field that contains:

A useful option if you are a bad smeller

to:

A useful option if you are a bad speller

[[:>:]]

End of word

Matches text at the end of a word.

As with Beginning of word.

()

Expression

An expression is used to group a number of characters together in order to apply the same wildcard character to the group.

For example, a field contains:

abcabc abd

To locate instances where abc appears twice and replace it with cba:

  1. Select the Expression wildcard:

    () displays in the Text to find field.

  2. Enter (abc){2}
  3. In the Replace with field enter cba
  4. Run the Global Replace.

    The field will contain:

    cba abd

|

Alternative

Use where more than one alternate character forms part of the search.

For example:

c(ar|ul)t

matches

cart or cult

[^x]

Not a character

Specifies a character that is not to be part of the search.

For example:

c[^ao]t

would locate and replace cut but not cat or cot.

{d,d}

Num occurrences

Specifies the number of times a letter is repeated in the search term.

For example, a field contains:

abc abcc, abccc, abcccc, abccccc

To locate instances where C repeats from 2 to 5 times and replace with x:

  1. Select the Num occurrences wildcard:

    {d,d} displays in the Text to find field.

  2. Enter c{2,5}
  3. In the Replace with field enter x
  4. Run the Global Replace.

    The field will contain:

    abc abx abx abx abx

+

Previous 1 or more

Matches one or more occurrences of the previous character.

For example, a field contains:

ab abc, abcc, abccc, abcccc

To locate instances where C occurs once or more than once and replace with d:

  1. Select the Previous 1 or more wildcard:

    + displays in the Text to find field.

  2. Enter c+
  3. In the Replace with field enter d
  4. Run the Global Replace.

    The field will contain:

    ab abd abd abd abd

    Example 2, a field contains:

    ab abc, abcc, abccc, abcccc

    To locate instances where C occurs once or more in combination with ab and replace the abc+ combination with d:

  5. Select the Previous 1 or more wildcard:

    + displays in the Text to find field.

  6. Enter ab c+
  7. In the Replace with field enter d
  8. Run the Global Replace.

    The field will contain:

    ab d d d d

*

Previous 0 or more

Matches zero or more occurrences of the previous character.

For example, a field contains:

ab abc, abcc, abccc, abcccc

To locate instances where c does or does not occur in combination with ab and replace with x:

  1. Select the Previous 0 or more wildcard:

    * displays in the Text to find field.

  2. Enter ab c*
  3. In the Replace with field enter x
  4. Run the Global Replace.

    The field will contain:

    x x x x x

?

Previous 0 or 1

Matches zero or one occurrence of the previous character.

For example, locating:

abc?

and replacing with:

x

will change a field that contains:

ab abc, abcc

to:

x x xc

\x

Wildcard escape

The wildcard escape character removes any special meaning associated with a character, e.g. abc\? matches abc? rather than ab or abc.

Note: Examples of how to use wildcards in a multi-language environment are available here. These examples may be useful for understanding how Global Replace operates.